<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>SWM34S_LVGL7.11_SWMUI: C:/Users/DELL/Desktop/Commit/lvgl/SWM34S_LVGL7.11_SWMUI_20230515/APP/BSP/dev_dac.c 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">SWM34S_LVGL7.11_SWMUI<span id="projectnumber">&#160;V7.9</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.5 -->
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_0ca16891106f5a3e9ad635a0d6c5f98f.html">APP</a></li><li class="navelem"><a class="el" href="dir_4ca18d753a70f6eada20fde478bd3fc8.html">BSP</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">dev_dac.c</div></div>
</div><!--header-->
<div class="contents">
<a href="dev__dac_8c.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &quot;<a class="code" href="dev__dac_8h.html">dev_dac.h</a>&quot;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="preprocessor">#include &quot;<a class="code" href="version_8h.html">version.h</a>&quot;</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span> </div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="comment">/*******************************************************************************************************************************************</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span><span class="comment"> * Private Define</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span><span class="comment"> *******************************************************************************************************************************************/</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a8e74136d0e6258d00ec44a39df1141ff">   29</a></span><span class="preprocessor">#define DAC_TIMR                    TIMR0</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a829446cfb366509093b5879438939a44">   30</a></span><span class="preprocessor">#define DAC_DMA_HS                  DMA_EXHS_TIMR0</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span> </div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span><span class="preprocessor">#if (SWM34S_LCM_PCBV == SWM34SCE_PIN48_A2)</span></div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span><span class="comment">/* 没有多余 IO 实现 MUTE STB */</span></div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span> </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#ad4a0e73622f8d4d6f9f97292ee7d4456">   36</a></span><span class="preprocessor">    #define MUTE_STB_INIT()             </span><span class="comment">//GPIO_Init(GPIOD, PIN11, 1, 0, 0, 0)</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a360815b2ffc6e513c2978c588e8c0b59">   38</a></span><span class="comment"></span>    #define MUTE_STB_SET(enable)        <span class="comment">//( GPIOD-&gt;DATAPIN11 = ( (enable) ? 1 : 0 ) )</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span> </div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span><span class="preprocessor">#elif (SWM34S_LCM_PCBV == SWM34SRE_PIN64_A001)</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span> </div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span><span class="preprocessor">    #define MUTE_STB_INIT()         GPIO_Init(GPIOM, PIN3, 1, 0, 0, 0)</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span><span class="preprocessor">    #define MUTE_STB_SET(enable)    ( GPIOM-&gt;DATAPIN3 = ( (enable) ? 1 : 0 ) )</span></div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span> </div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span><span class="preprocessor">#else </span><span class="comment">/* SWM34SVET6_Pin100 */</span><span class="preprocessor"></span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span> </div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span><span class="preprocessor">    #define MUTE_STB_INIT()         GPIO_Init(GPIOD, PIN11, 1, 0, 0, 0)</span></div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span><span class="preprocessor">    #define MUTE_STB_SET(enable)    ( GPIOD-&gt;DATAPIN11 = ( (enable) ? 1 : 0 ) )</span></div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span> </div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span><span class="comment">/*******************************************************************************************************************************************</span></div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span><span class="comment"> * Public Constant</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span><span class="comment"> *******************************************************************************************************************************************/</span></div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#aae6320f87b86b6a56b02cf050eb8a0b8">   59</a></span><span class="keyword">const</span> uint16_t <a class="code hl_variable" href="dev__dac_8c.html#aae6320f87b86b6a56b02cf050eb8a0b8">Sin_Data</a>[100] = {</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span>    2048,  2176,  2304,  2431,  2557,  2680,  2801,  2919,  3034,  3144,</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span>    3251,  3352,  3449,  3540,  3625,  3704,  3776,  3841,  3900,  3951,</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>    3994,  4030,  4058,  4078,  4090,  4095,  4090,  4078,  4058,  4030,</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>    3994,  3951,  3900,  3841,  3776,  3704,  3625,  3540,  3449,  3352,</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span>    3251,  3144,  3034,  2919,  2801,  2680,  2557,  2431,  2304,  2176,</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span>    2047,  1919,  1791,  1664,  1538,  1415,  1294,  1176,  1061,   951,</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>     844,   743,   646,   555,   470,   391,   319,   254,   195,   144,</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span>     101,    65,    37,    17,     5,     1,     5,    17,    37,    65,</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>     101,   144,   195,   254,   319,   391,   470,   555,   646,   743,</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span>     844,   951,  1061,  1176,  1294,  1415,  1538,  1664,  1791,  1919,</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>};</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span> </div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span><span class="comment">/*******************************************************************************************************************************************</span></div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span><span class="comment"> * Private Variable</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span><span class="comment"> *******************************************************************************************************************************************/</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31a">   76</a></span><span class="keyword">typedef</span> <span class="keyword">enum</span></div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span>{</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa0d077f5b932ce05e5b9f30c6087a2f31">   78</a></span>    <a class="code hl_enumvalue" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa0d077f5b932ce05e5b9f30c6087a2f31">NO</a> = 0, </div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>    <a class="code hl_enumvalue" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa2bc49ec37d6a5715dd23e85f1ff5bb59">OK</a>      </div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span>    <span class="comment">/* 可以枚举拓展 ++ 累计触发次数 */</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa2bc49ec37d6a5715dd23e85f1ff5bb59">   81</a></span>} <a class="code hl_enumeration" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31a">irq_flag_t</a>;</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span> </div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a310355cb988ed3677ca354b6a0ae5335">   83</a></span><span class="keyword">static</span> <span class="keyword">volatile</span> <a class="code hl_enumeration" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31a">irq_flag_t</a> <a class="code hl_variable" href="dev__dac_8c.html#a310355cb988ed3677ca354b6a0ae5335">IRQ_Flag_Audio</a> = <a class="code hl_enumvalue" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa0d077f5b932ce05e5b9f30c6087a2f31">NO</a>; </div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span><span class="comment">/*******************************************************************************************************************************************</span></div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span><span class="comment"> * Public Function</span></div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span><span class="comment"> *******************************************************************************************************************************************/</span></div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a8f4d838d3f9b79ef8e1fa1bc046fc590">   91</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__dac_8c.html#a8f4d838d3f9b79ef8e1fa1bc046fc590">isr_dma_dac</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>{</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>    <span class="keywordflow">if</span> (DMA_CH_INTStat(<a class="code hl_define" href="dev__dac_8h.html#a5cf167f3b1930852accd27d796f47195">DAC_DMA_CHN</a>, DMA_IT_DONE))</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>    {</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>        DMA_CH_INTClr(<a class="code hl_define" href="dev__dac_8h.html#a5cf167f3b1930852accd27d796f47195">DAC_DMA_CHN</a>, DMA_IT_DONE);</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span> </div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span>        <a class="code hl_variable" href="dev__dac_8c.html#a310355cb988ed3677ca354b6a0ae5335">IRQ_Flag_Audio</a> = <a class="code hl_enumvalue" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa2bc49ec37d6a5715dd23e85f1ff5bb59">OK</a>;</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>    }</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span>}</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span> </div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#ab18d2dbe4e762641f948bc31b52234f4">  106</a></span>uint8_t <a class="code hl_function" href="dev__dac_8c.html#ab18d2dbe4e762641f948bc31b52234f4">dac_dma_transfer_done</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span>{</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span>    <span class="keywordflow">if</span> (<a class="code hl_variable" href="dev__dac_8c.html#a310355cb988ed3677ca354b6a0ae5335">IRQ_Flag_Audio</a> == <a class="code hl_enumvalue" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa2bc49ec37d6a5715dd23e85f1ff5bb59">OK</a>)</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span>    {</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span>        <a class="code hl_variable" href="dev__dac_8c.html#a310355cb988ed3677ca354b6a0ae5335">IRQ_Flag_Audio</a> = <a class="code hl_enumvalue" href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa0d077f5b932ce05e5b9f30c6087a2f31">NO</a>;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span>        <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span>    }</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span>    <span class="keywordflow">return</span> 1;</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span>}</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span> </div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#aab3eb615ca98a910e727b600de131c18">  119</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__dac_8c.html#aab3eb615ca98a910e727b600de131c18">dac_port_init</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>{</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span><span class="preprocessor">#if (SWM34S_LCM_PCBV != SWM34SCE_PIN48_A2)</span></div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span>    <span class="comment">/* MPU 屏 RGB 模式下 D2 用作 SPI 初始化片选信号 */</span></div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span>    PORT_Init(PORTD, PIN2, PORTD_PIN2_DAC_OUT, 0);</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno">  125</span>    </div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno">  126</span>    <a class="code hl_define" href="dev__dac_8c.html#ad4a0e73622f8d4d6f9f97292ee7d4456">MUTE_STB_INIT</a>();</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno">  127</span>    <a class="code hl_define" href="dev__dac_8c.html#a360815b2ffc6e513c2978c588e8c0b59">MUTE_STB_SET</a>(0);</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span>}</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno">  129</span> </div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#ae6564f4952cc109138c86b644e9585d9">  133</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__dac_8c.html#ae6564f4952cc109138c86b644e9585d9">dac_port_deinit</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>{</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span><span class="preprocessor">#if (SWM34S_LCM_PCBV != SWM34SCE_PIN48_A2)</span></div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span>    <span class="comment">/* MPU 屏 RGB 模式下 D2 用作 SPI 初始化片选信号 */</span></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span>    GPIO_Init(GPIOD, PIN2, 0, 0, 1, 0);</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span>    <span class="comment">//GPIO_AtomicClrBit(GPIOD, PIN2);</span></div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno">  140</span>    </div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno">  141</span>    <a class="code hl_define" href="dev__dac_8c.html#ad4a0e73622f8d4d6f9f97292ee7d4456">MUTE_STB_INIT</a>();</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno">  142</span>    <a class="code hl_define" href="dev__dac_8c.html#a360815b2ffc6e513c2978c588e8c0b59">MUTE_STB_SET</a>(1);</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno">  143</span>}</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno">  144</span> </div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a6e622fafee8436bf9cf9f6b120352e3c">  148</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__dac_8c.html#a6e622fafee8436bf9cf9f6b120352e3c">dac_init</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno">  149</span>{</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span>    <a class="code hl_function" href="dev__dac_8c.html#aab3eb615ca98a910e727b600de131c18">dac_port_init</a>();</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span>    <a class="code hl_define" href="dev__dac_8c.html#a360815b2ffc6e513c2978c588e8c0b59">MUTE_STB_SET</a>(1);</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span> </div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span>    DAC_Init(DAC, DAC_FORMAT_MSB12B); <span class="comment">/* DHR 高 12 位 传输给 DOR */</span></div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span>    DAC_Open(DAC);</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span>    </div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span>    DAC-&gt;DHR = (4095 &gt;&gt; 1) &lt;&lt; 4; <span class="comment">/* 高 12 bit 有效, 输出 1.65V 白噪声 */</span></div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span>    <span class="keywordflow">while</span> (DAC-&gt;SR &amp; DAC_SR_DHRFULL_Msk) __NOP();</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span>}</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span> </div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a1cbb394145c7d8b7a7d17fc24a2d6406">  169</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__dac_8c.html#a1cbb394145c7d8b7a7d17fc24a2d6406">dac_dma_init</a>(uint16_t *addr, uint32_t count, uint32_t frequency)</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno">  170</span>{</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno">  171</span>    DMA_InitStructure DMA_initStruct;</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno">  172</span> </div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno">  173</span>    DMA_initStruct.Mode = DMA_MODE_SINGLE;</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno">  174</span>    DMA_initStruct.Unit = DMA_UNIT_HALFWORD;</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno">  175</span>    DMA_initStruct.Count = count;</div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno">  176</span>    DMA_initStruct.SrcAddr = (uint32_t)addr;</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno">  177</span>    DMA_initStruct.SrcAddrInc = 1;</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno">  178</span>    DMA_initStruct.DstAddr = (uint32_t)&amp;DAC-&gt;DHR;</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno">  179</span>    DMA_initStruct.DstAddrInc = 0;</div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno">  180</span>    DMA_initStruct.Priority = DMA_PRI_LOW;</div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno">  181</span>    DMA_initStruct.INTEn = DMA_IT_DONE;</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno">  182</span>    </div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno">  183</span>    DMA_initStruct.Handshake = <a class="code hl_define" href="dev__dac_8c.html#a829446cfb366509093b5879438939a44">DAC_DMA_HS</a>; <span class="comment">/* 握手信号由外部 TIMR_x 触发 (注意: DMA 配置为外部 trigger 信号启动时, DMA 其他通道不工作, 此问题只能尽量避让绕开应用) */</span></div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno">  184</span> </div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno">  185</span>    DMA_CH_Init(<a class="code hl_define" href="dev__dac_8h.html#a5cf167f3b1930852accd27d796f47195">DAC_DMA_CHN</a>, &amp;DMA_initStruct);</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno">  186</span>    DMA_CH_Open(<a class="code hl_define" href="dev__dac_8h.html#a5cf167f3b1930852accd27d796f47195">DAC_DMA_CHN</a>);</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno">  187</span>    </div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno">  188</span>    <span class="comment">/* 控制按音频采样率播放音频, 每 ? 微秒 触发 DMA 向 DAC 搬运 1 个 Uint */</span></div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno">  189</span>    TIMR_Init(<a class="code hl_define" href="dev__dac_8c.html#a8e74136d0e6258d00ec44a39df1141ff">DAC_TIMR</a>, TIMR_MODE_TIMER, CyclesPerUs, 1000000 / frequency, 0);</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno">  190</span>    TIMR_Start(<a class="code hl_define" href="dev__dac_8c.html#a8e74136d0e6258d00ec44a39df1141ff">DAC_TIMR</a>);</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno">  191</span> </div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno">  192</span>    <a class="code hl_define" href="dev__dac_8c.html#a360815b2ffc6e513c2978c588e8c0b59">MUTE_STB_SET</a>(0);</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno">  193</span>}</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno">  194</span> </div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"><a class="line" href="dev__dac_8c.html#a7274a6adbc1a4a9f5a2f27be8d1225e4">  198</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__dac_8c.html#a7274a6adbc1a4a9f5a2f27be8d1225e4">dac_dma_deinit</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno">  199</span>{</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span>    <a class="code hl_define" href="dev__dac_8c.html#a360815b2ffc6e513c2978c588e8c0b59">MUTE_STB_SET</a>(1);</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno">  201</span> </div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno">  202</span>    TIMR_Stop(<a class="code hl_define" href="dev__dac_8c.html#a8e74136d0e6258d00ec44a39df1141ff">DAC_TIMR</a>); <span class="comment">/* 关闭触发源 */</span></div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno">  203</span>    </div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno">  204</span>    DMA_CH_Close(<a class="code hl_define" href="dev__dac_8h.html#a5cf167f3b1930852accd27d796f47195">DAC_DMA_CHN</a>);</div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno">  205</span>    </div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno">  206</span>    DAC-&gt;DHR = (4095 &gt;&gt; 1) &lt;&lt; 4; <span class="comment">/* 高 12 bit 有效, 输出 1.65V 白噪声 */</span></div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno">  207</span>    <span class="keywordflow">while</span> (DAC-&gt;SR &amp; DAC_SR_DHRFULL_Msk) __NOP();</div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno">  208</span>    </div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno">  209</span>    <span class="comment">/* 关闭后须重新初始化 DAC, 一般不关</span></div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno">  210</span><span class="comment">    DAC_Close(DAC);*/</span></div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno">  211</span>}</div>
<div class="ttc" id="adev__dac_8c_html_a1cbb394145c7d8b7a7d17fc24a2d6406"><div class="ttname"><a href="dev__dac_8c.html#a1cbb394145c7d8b7a7d17fc24a2d6406">dac_dma_init</a></div><div class="ttdeci">void dac_dma_init(uint16_t *addr, uint32_t count, uint32_t frequency)</div><div class="ttdoc">DAC_DMA 配置, 采用 TIMR 触发 DMA 步进传输</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00169">dev_dac.c:169</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a310355cb988ed3677ca354b6a0ae5335"><div class="ttname"><a href="dev__dac_8c.html#a310355cb988ed3677ca354b6a0ae5335">IRQ_Flag_Audio</a></div><div class="ttdeci">static volatile irq_flag_t IRQ_Flag_Audio</div><div class="ttdoc">DAC_DMA 传输完成标志</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00083">dev_dac.c:83</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a360815b2ffc6e513c2978c588e8c0b59"><div class="ttname"><a href="dev__dac_8c.html#a360815b2ffc6e513c2978c588e8c0b59">MUTE_STB_SET</a></div><div class="ttdeci">#define MUTE_STB_SET(enable)</div><div class="ttdoc">MUTE 脚高电平静音控制 (eg : enable = 1 使能静音; enable = 0 导通声音)</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00038">dev_dac.c:38</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a3d600ad47f709a0dcfa5cbf1a00fc31a"><div class="ttname"><a href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31a">irq_flag_t</a></div><div class="ttdeci">irq_flag_t</div><div class="ttdoc">中断标志</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00076">dev_dac.c:77</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a3d600ad47f709a0dcfa5cbf1a00fc31aa0d077f5b932ce05e5b9f30c6087a2f31"><div class="ttname"><a href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa0d077f5b932ce05e5b9f30c6087a2f31">NO</a></div><div class="ttdeci">@ NO</div><div class="ttdoc">未触发中断</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00078">dev_dac.c:78</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a3d600ad47f709a0dcfa5cbf1a00fc31aa2bc49ec37d6a5715dd23e85f1ff5bb59"><div class="ttname"><a href="dev__dac_8c.html#a3d600ad47f709a0dcfa5cbf1a00fc31aa2bc49ec37d6a5715dd23e85f1ff5bb59">OK</a></div><div class="ttdeci">@ OK</div><div class="ttdoc">已触发中断</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00081">dev_dac.c:79</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a6e622fafee8436bf9cf9f6b120352e3c"><div class="ttname"><a href="dev__dac_8c.html#a6e622fafee8436bf9cf9f6b120352e3c">dac_init</a></div><div class="ttdeci">void dac_init(void)</div><div class="ttdoc">初始化 DAC 模块</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00148">dev_dac.c:148</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a7274a6adbc1a4a9f5a2f27be8d1225e4"><div class="ttname"><a href="dev__dac_8c.html#a7274a6adbc1a4a9f5a2f27be8d1225e4">dac_dma_deinit</a></div><div class="ttdeci">void dac_dma_deinit(void)</div><div class="ttdoc">DAC_DMA 配置恢复初始默认状态</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00198">dev_dac.c:198</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a829446cfb366509093b5879438939a44"><div class="ttname"><a href="dev__dac_8c.html#a829446cfb366509093b5879438939a44">DAC_DMA_HS</a></div><div class="ttdeci">#define DAC_DMA_HS</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00030">dev_dac.c:30</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a8e74136d0e6258d00ec44a39df1141ff"><div class="ttname"><a href="dev__dac_8c.html#a8e74136d0e6258d00ec44a39df1141ff">DAC_TIMR</a></div><div class="ttdeci">#define DAC_TIMR</div><div class="ttdoc">DAC 配置宏</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00029">dev_dac.c:29</a></div></div>
<div class="ttc" id="adev__dac_8c_html_a8f4d838d3f9b79ef8e1fa1bc046fc590"><div class="ttname"><a href="dev__dac_8c.html#a8f4d838d3f9b79ef8e1fa1bc046fc590">isr_dma_dac</a></div><div class="ttdeci">void isr_dma_dac(void)</div><div class="ttdoc">DMA ISR Callback (DAC 所用的通道中断触发处理)</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00091">dev_dac.c:91</a></div></div>
<div class="ttc" id="adev__dac_8c_html_aab3eb615ca98a910e727b600de131c18"><div class="ttname"><a href="dev__dac_8c.html#aab3eb615ca98a910e727b600de131c18">dac_port_init</a></div><div class="ttdeci">void dac_port_init(void)</div><div class="ttdoc">配置 DAC 驱动端口以及功放静音控制脚, 开启声音</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00119">dev_dac.c:119</a></div></div>
<div class="ttc" id="adev__dac_8c_html_aae6320f87b86b6a56b02cf050eb8a0b8"><div class="ttname"><a href="dev__dac_8c.html#aae6320f87b86b6a56b02cf050eb8a0b8">Sin_Data</a></div><div class="ttdeci">const uint16_t Sin_Data[100]</div><div class="ttdoc">正弦波音频 - DAC 测试</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00059">dev_dac.c:59</a></div></div>
<div class="ttc" id="adev__dac_8c_html_ab18d2dbe4e762641f948bc31b52234f4"><div class="ttname"><a href="dev__dac_8c.html#ab18d2dbe4e762641f948bc31b52234f4">dac_dma_transfer_done</a></div><div class="ttdeci">uint8_t dac_dma_transfer_done(void)</div><div class="ttdoc">DAC DMA 判断是否传输完成</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00106">dev_dac.c:106</a></div></div>
<div class="ttc" id="adev__dac_8c_html_ad4a0e73622f8d4d6f9f97292ee7d4456"><div class="ttname"><a href="dev__dac_8c.html#ad4a0e73622f8d4d6f9f97292ee7d4456">MUTE_STB_INIT</a></div><div class="ttdeci">#define MUTE_STB_INIT()</div><div class="ttdoc">MUTE 脚初始化输出</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00036">dev_dac.c:36</a></div></div>
<div class="ttc" id="adev__dac_8c_html_ae6564f4952cc109138c86b644e9585d9"><div class="ttname"><a href="dev__dac_8c.html#ae6564f4952cc109138c86b644e9585d9">dac_port_deinit</a></div><div class="ttdeci">void dac_port_deinit(void)</div><div class="ttdoc">恢复 DAC 驱动端口以及功放静音控制脚的默认状态, 使能静音</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8c_source.html#l00133">dev_dac.c:133</a></div></div>
<div class="ttc" id="adev__dac_8h_html"><div class="ttname"><a href="dev__dac_8h.html">dev_dac.h</a></div><div class="ttdoc">DAC 音频播放</div></div>
<div class="ttc" id="adev__dac_8h_html_a5cf167f3b1930852accd27d796f47195"><div class="ttname"><a href="dev__dac_8h.html#a5cf167f3b1930852accd27d796f47195">DAC_DMA_CHN</a></div><div class="ttdeci">#define DAC_DMA_CHN</div><div class="ttdef"><b>Definition:</b> <a href="dev__dac_8h_source.html#l00028">dev_dac.h:28</a></div></div>
<div class="ttc" id="aversion_8h_html"><div class="ttname"><a href="version_8h.html">version.h</a></div><div class="ttdoc">版本/目标控制</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5
</small></address>
</body>
</html>
